package com.app.worldcupapp;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.squareup.picasso.Picasso;

import java.util.List;


class MyAdapter extends BaseAdapter {
    List<MyBean1.ListBean> list;
    Context context;

    public MyAdapter() {
        super();
    }

    public MyAdapter(List<MyBean1.ListBean> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {

        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        convertView = View.inflate(context, R.layout.item_listview, null);
        TextView id = convertView.findViewById(R.id.tv_teamId);
        TextView name = convertView.findViewById(R.id.tv_teamName);
        ImageView pic = convertView.findViewById(R.id.iv_teamPic);
        id.setText(list.get(position).getTeamId());
        name.setText(list.get(position).getTeamName());
        Picasso.with(context).load("http://10.1.62.14:8080" + list.get(position).getTeamPic()).into(pic);
        return convertView;
    }
}